package com.wsb.wetchat.service.impl;

import com.wsb.wetchat.dao.User;
import com.wsb.wetchat.mapper.UserMapper;
import com.wsb.wetchat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wang shaobo
 * @date 2022/6/23  17:32
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public void addUser(User user) {
        //校验用户是否存在,如果存在返回已添加

        userMapper.addUser(user);

    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateUser(User user) {
        int update = userMapper.update(user);
        int i = 1/0;
        return update;
    }

    @Override
    public User queryById(int id) {
        return userMapper.queryUserById(id);
    }
}
